Option Strict Off
Option Explicit On
Friend Class frmErrorBox
	Inherits System.Windows.Forms.Form
	'This is the error box that is displayed to the user when an error occurs
	Dim WaitForUser As Boolean
	Public Sub ErrorMessageBox() 'Use this routine when an error has been called
		Me.Text = "The Helium Frog Animator V" & Version
		WaitForUser = False
		Me.Left = VB6.TwipsToPixelsX((VB6.PixelsToTwipsX(frmMainForm.Width) / 2) - ((VB6.PixelsToTwipsX(Me.Width)) / 2))
		Me.Top = VB6.TwipsToPixelsY((VB6.PixelsToTwipsY(frmMainForm.Height) / 2) - ((VB6.PixelsToTwipsY(Me.Height)) / 2))
		lblErrorCode.Text = "HELIUM FROG ERROR CODE " & ErrorCodeNo
		lblErrorType.Text = ErrorDescription
		Me.Show()
		Beep()
		WaitForUser = True
		Do While WaitForUser = True 'Just Loop around until the user hit a button
			BringWindowToTop(Me.Handle.ToInt32) 'Bring the Errorbox always to the top, this prevents focus on any other window.
			System.Windows.Forms.Application.DoEvents()
		Loop 
	End Sub
	Private Sub cmdReportError_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdReportError.Click 'Report error (ie email martin price with error)
		
		Call GenerateSettingsData() 'call the subroutine in the LoadSettings module to generate the text contailing the current settings
		
		'Modify with a few extra bits of data that may be needed.
		TextBody = "** These are the settings when I encountered the problem. Attached are my settings from my previous OK session." & Chr(13) & Chr(10) & " I had captured " & FrameNum & " frames when the problem occured" & Chr(13) & Chr(10) & " " & Chr(13) & Chr(10) & TextBody
		
		'Now send the email
		MAPISession1.DownLoadMail = False 'Dont download any mail from the server
		MAPISession1.LogonUI = True
		MAPISession1.SignOn() 'Open the sesson
		MAPISession1.NewSession = True
		MAPIMessages1.SessionID = MAPISession1.SessionID
		
		MAPIMessages1.Compose() 'Clears buffer and creates a new message
		MAPIMessages1.RecipAddress = TargetEmail 'Set the target email address
		MAPIMessages1.AddressResolveUI = False 'Will flag an error if the target address is not found
		MAPIMessages1.ResolveName()
		MAPIMessages1.MsgSubject = "Error on Version " & Version & " - Error code No " & ErrorCodeNo 'The title of the email
		MAPIMessages1.MsgNoteText = TextBody 'The body of text in the email
		MAPIMessages1.AttachmentPathName = My.Application.Info.DirectoryPath & "\Settings_User.txt" 'Attach a file to the email
		
		MAPIMessages1.Send(False)
		MAPISession1.SignOff() 'Close the session
		
		lblErrorType.Text = "Thank You. Your help in debugging the code is appreciated."
		cmdReportError.Visible = False
	End Sub
	Private Sub cmdJustContinue_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdJustContinue.Click 'Just try to continue with program
		WaitForUser = False
	End Sub
End Class